package org.framework.lazy.cloud.network.heartbeat.server.standalone.application.impl;

import jakarta.annotation.Resource;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.LazyProxyPerDayFlowApplication;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.assembler.LazyProxyPerDayFlowDTOAssembler;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.command.lazy.proxy.per.day.flow.*;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.application.dto.LazyProxyPerDayFlowDTO;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.proxy.per.day.flow.LazyProxyPerDayFlow;
import org.framework.lazy.cloud.network.heartbeat.server.standalone.domain.model.lazy.proxy.per.day.flow.LazyProxyPerDayFlowRepository;
import org.wu.framework.lazy.orm.database.lambda.domain.LazyPage;
import org.wu.framework.lazy.orm.web.plus.stereotype.LazyApplication;
import org.wu.framework.web.response.Result;

import java.util.List;
import java.util.stream.Collectors;

/**
 * describe 每日统计代理流量
 *
 * @author Jia wei Wu
 * @date 2025/06/06 11:39 晚上
 * @see org.wu.framework.lazy.orm.core.persistence.reverse.lazy.ddd.DefaultDDDLazyApplicationImpl
 **/
@LazyApplication
public class LazyProxyPerDayFlowApplicationImpl implements LazyProxyPerDayFlowApplication {

    @Resource
    LazyProxyPerDayFlowRepository lazyProxyPerDayFlowRepository;

    /**
     * describe 新增每日统计代理流量
     *
     * @param lazyProxyPerDayFlowStoryCommand 新增每日统计代理流量
     * @return {@link Result<LazyProxyPerDayFlow>} 每日统计代理流量新增后领域对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Override
    public Result<LazyProxyPerDayFlow> story(LazyProxyPerDayFlowStoryCommand lazyProxyPerDayFlowStoryCommand) {
        LazyProxyPerDayFlow lazyProxyPerDayFlow = LazyProxyPerDayFlowDTOAssembler.INSTANCE.toLazyProxyPerDayFlow(lazyProxyPerDayFlowStoryCommand);
        return lazyProxyPerDayFlowRepository.story(lazyProxyPerDayFlow);
    }

    /**
     * describe 批量新增每日统计代理流量
     *
     * @param lazyProxyPerDayFlowStoryCommandList 批量新增每日统计代理流量
     * @return {@link Result<List<LazyProxyPerDayFlow>>} 每日统计代理流量新增后领域对象集合
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Override
    public Result<List<LazyProxyPerDayFlow>> batchStory(List<LazyProxyPerDayFlowStoryCommand> lazyProxyPerDayFlowStoryCommandList) {
        List<LazyProxyPerDayFlow> lazyProxyPerDayFlowList = lazyProxyPerDayFlowStoryCommandList.stream().map(LazyProxyPerDayFlowDTOAssembler.INSTANCE::toLazyProxyPerDayFlow).collect(Collectors.toList());
        return lazyProxyPerDayFlowRepository.batchStory(lazyProxyPerDayFlowList);
    }

    /**
     * describe 更新每日统计代理流量
     *
     * @param lazyProxyPerDayFlowUpdateCommand 更新每日统计代理流量
     * @return {@link Result<LazyProxyPerDayFlow>} 每日统计代理流量领域对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Override
    public Result<LazyProxyPerDayFlow> updateOne(LazyProxyPerDayFlowUpdateCommand lazyProxyPerDayFlowUpdateCommand) {
        LazyProxyPerDayFlow lazyProxyPerDayFlow = LazyProxyPerDayFlowDTOAssembler.INSTANCE.toLazyProxyPerDayFlow(lazyProxyPerDayFlowUpdateCommand);
        return lazyProxyPerDayFlowRepository.story(lazyProxyPerDayFlow);
    }

    /**
     * describe 查询单个每日统计代理流量
     *
     * @param lazyProxyPerDayFlowQueryOneCommand 查询单个每日统计代理流量
     * @return {@link Result<LazyProxyPerDayFlowDTO>} 每日统计代理流量DTO对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Override
    public Result<LazyProxyPerDayFlowDTO> findOne(LazyProxyPerDayFlowQueryOneCommand lazyProxyPerDayFlowQueryOneCommand) {
        LazyProxyPerDayFlow lazyProxyPerDayFlow = LazyProxyPerDayFlowDTOAssembler.INSTANCE.toLazyProxyPerDayFlow(lazyProxyPerDayFlowQueryOneCommand);
        return lazyProxyPerDayFlowRepository.findOne(lazyProxyPerDayFlow).convert(LazyProxyPerDayFlowDTOAssembler.INSTANCE::fromLazyProxyPerDayFlow);
    }

    /**
     * describe 查询多个每日统计代理流量
     *
     * @param lazyProxyPerDayFlowQueryListCommand 查询多个每日统计代理流量
     * @return {@link Result<List<LazyProxyPerDayFlowDTO>>} 每日统计代理流量DTO对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Override
    public Result<List<LazyProxyPerDayFlowDTO>> findList(LazyProxyPerDayFlowQueryListCommand lazyProxyPerDayFlowQueryListCommand) {
        LazyProxyPerDayFlow lazyProxyPerDayFlow = LazyProxyPerDayFlowDTOAssembler.INSTANCE.toLazyProxyPerDayFlow(lazyProxyPerDayFlowQueryListCommand);
        return lazyProxyPerDayFlowRepository.findList(lazyProxyPerDayFlow).convert(lazyProxyPerDayFlows -> lazyProxyPerDayFlows.stream().map(LazyProxyPerDayFlowDTOAssembler.INSTANCE::fromLazyProxyPerDayFlow).collect(Collectors.toList()));
    }

    /**
     * describe 分页查询多个每日统计代理流量
     *
     * @param lazyProxyPerDayFlowQueryListCommand 分页查询多个每日统计代理流量
     * @return {@link Result<LazyPage<LazyProxyPerDayFlowDTO>>} 分页每日统计代理流量DTO对象
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Override
    public Result<LazyPage<LazyProxyPerDayFlowDTO>> findPage(int size, int current, LazyProxyPerDayFlowQueryListCommand lazyProxyPerDayFlowQueryListCommand) {
        LazyProxyPerDayFlow lazyProxyPerDayFlow = LazyProxyPerDayFlowDTOAssembler.INSTANCE.toLazyProxyPerDayFlow(lazyProxyPerDayFlowQueryListCommand);
        return lazyProxyPerDayFlowRepository.findPage(size, current, lazyProxyPerDayFlow).convert(page -> page.convert(LazyProxyPerDayFlowDTOAssembler.INSTANCE::fromLazyProxyPerDayFlow));
    }

    /**
     * describe 删除每日统计代理流量
     *
     * @param lazyProxyPerDayFlowRemoveCommand 删除每日统计代理流量
     * @return {@link Result<LazyProxyPerDayFlow>} 每日统计代理流量
     * @author Jia wei Wu
     * @date 2025/06/06 11:39 晚上
     **/

    @Override
    public Result<LazyProxyPerDayFlow> remove(LazyProxyPerDayFlowRemoveCommand lazyProxyPerDayFlowRemoveCommand) {
        LazyProxyPerDayFlow lazyProxyPerDayFlow = LazyProxyPerDayFlowDTOAssembler.INSTANCE.toLazyProxyPerDayFlow(lazyProxyPerDayFlowRemoveCommand);
        return lazyProxyPerDayFlowRepository.remove(lazyProxyPerDayFlow);
    }

}